home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / doom / quake.zip / HIPGRAPL.ZIP / HIPCLOCK.QC < prev    next >
Text File  |  1997-01-16  |  2KB  |  88 lines

  1. /* Clock QuickC program
  2.    By Jim Dose'  11/25/96
  3.    Copyright (c)1996 Hipnotic Interactive, Inc.
  4.    All rights reserved.
  5.    Do not distribute.
  6. */
  7.  
  8. void() clock_setpos =
  9.    {
  10.    local float pos;
  11.    local float ang;
  12.    local float seconds;
  13.    local string temp;
  14.  
  15.    // How much time has elapsed.
  16.    seconds = time + self.cnt;
  17.  
  18.    // divide by time it takes for one revolution
  19.    pos = seconds / self.count;
  20.  
  21.    // chop off non-fractional component
  22.    pos = pos - floor( pos );
  23.  
  24.    ang = 360 * pos;
  25.    if ( self.event )
  26.       {
  27.       if ( self.ltime > ang )
  28.          {
  29.          // past twelve
  30.          temp = self.target;
  31.          self.target = self.event;
  32.          SUB_UseTargets();
  33.          self.target = temp;
  34.          }
  35.       }
  36.  
  37.    self.angles_x = ang * self.movedir_x;
  38.    self.angles_y = ang * self.movedir_y;
  39.    self.angles_z = ang * self.movedir_z;
  40.    RotateTargetsFinal();
  41.  
  42.    self.ltime = ang;
  43.    };
  44.  
  45. void() clock_think =
  46.     {
  47.    clock_setpos();
  48.    self.nextthink = time + 1;
  49.    };
  50.  
  51. void() clock_firstthink =
  52.    {
  53.    LinkRotateTargets();
  54.    self.think = clock_think;
  55.    clock_think();
  56.    };
  57.  
  58. /*QUAKED func_clock (0 0 0.5) (0 0 0) (32 32 32)
  59. Creates one hand of a "clock".
  60.  
  61. Set the angle to be the direction the clock is facing.
  62.  
  63. "event" is the targetname of the entities to trigger when hand strikes 12.
  64. "cnt" is the time to start at.
  65. "count" is the # of seconds it takes to make a full revolution (seconds is 60, minutes 3600, hours 43200).  default is 60.
  66. */
  67.  
  68. void() func_clock =
  69.     {
  70.    local vector temp;
  71.  
  72.    self.classname = "clock";
  73.    self.think = clock_firstthink;
  74.    self.nextthink = time + 0.1;
  75.    self.ltime = time;
  76.    SetMovedir();
  77.    temp = self.movedir;
  78.    self.movedir_x = 0 - temp_y;
  79.    self.movedir_y = 0 - temp_z;
  80.    self.movedir_z = 0 - temp_x;
  81.  
  82.    if ( !self.count )
  83.       {
  84.       self.count = 60;
  85.       }
  86.    self.cnt = self.cnt * ( self.count / 12 );
  87.    };
  88.